#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
from module.config import conf
import sys,os

try:
    conf.load()
except:
    pass

from app import App

sys.path.append(os.path.dirname(__file__))
if os.path.dirname(__file__):
    os.chdir(os.path.dirname(__file__))

application = App()

RUN_WERKZEUG = 0
if __name__ == '__main__':
    if RUN_WERKZEUG:
        from werkzeug.serving import run_simple
        run_simple(conf.SERVER,conf.SPORT,application,use_reloader=True,use_debugger=True)
    else:
        from wsgiref.simple_server import make_server
        httpd = make_server(conf.SERVER,conf.SPORT,application)
        print "http://%s:%d" %(conf.SERVER,conf.SPORT)
        httpd.serve_forever()